home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3133 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.2 KB  |  50 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!marnold
  3. From: marnold@netcom.com (Matt Arnold)
  4. Subject: Re: [Q] Best way to "define" flag values?
  5. Message-ID: <marnoldDLKG7E.B3H@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. References: <marnoldDLIv9w.1s4@netcom.com> <cmanDLKAqG.Drt@netcom.com>
  8. Distribution: na
  9. Date: Mon, 22 Jan 1996 04:52:25 GMT
  10. Sender: marnold@netcom9.netcom.com
  11.  
  12. cman@netcom.com (Mike Austin) writes:
  13.  
  14. >Here's a little essay that I did a while ago.  I still think the same 
  15. >way now, but my views have broadened...
  16.  
  17. [essay snipped]
  18.  
  19. Well, after a quick pass, your "enumbit" proposal makes sense to me.  
  20. The C/C++ language certinaly lacks an elegant, type-safe, semi-automatic
  21. way to deal with flags in a globally consitent way.  This shortcoming
  22. is obviously the source of my original question. 
  23.  
  24. Sure, bit fields are a nice and compact way to store flag values, but
  25. they do not take the place of hand-tuned #define or enum values used for
  26. passing flags to functions.  You just can't really used bit fields
  27. conveniently for function parameters.
  28.  
  29. Sure, you can use enums to declare the values used for flags, but they 
  30. seem to offer little practical advantage over the traditional #define
  31. approach (yes, enums offer better encapsulation possiblities in C++, but
  32. they are no more convenient to use in the end than #defines, IMO).
  33.  
  34. Mike's essay, "Enumerations and Parameterless Macros", paints a nice 
  35. "what if" picture of how flags/bits could be better dealt with in C++ via
  36. new language support, but it does not really answer my question...
  37.  
  38. Has any one come up with a good way using the language as it stands?
  39.  
  40. PS: I did appreciate your posting, Mike.
  41.  
  42. Thanks,
  43. -------------------------------------------------------------------------
  44. Matt Arnold                       |        | ||| | |||| |  | | || ||
  45. marnold@netcom.com                |        | ||| | |||| |  | | || ||
  46. Boston, MA                        |      0 | ||| | |||| |  | | || ||
  47. 617.389.7384 (h) 617.576.2760 (w) |        | ||| | |||| |  | | || ||
  48. C++, MIDI, Win32/95 developer     |        | ||| 4 3 1   0 8 3 || ||
  49. -------------------------------------------------------------------------
  50.